<?php



namespace App\Http\Requests\ApiV2;

use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;

class AddressRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required|max:120',
            'phone' => 'required|max:11',
            'address_district' => 'required|max:50',
            'address_detail' => 'required|max:50',
            'province' => 'required|max:20',
            'city' => 'required|max:20',
            'district' => 'required|max:20',


        ];
    }

    public function messages()
    {
        return [
            'name.required' => __('请输入姓名'),
            'name.max' => __('姓名长度不能超过:size个字符', ['size' => 20]),
            'phone.required' => __('请输入手机号'),
            'address_district.required' => __('请输入所属省份'),
            'address_detail.required' => __('请输入详细地址'),
            'province.required' => __('请输入省份'),
            'city.required' => __('请输入城市'),
            'district' => __('请输入区域'),

        ];
    }

    public function filldata()
    {
        $userId =  Auth::id();
        return [
            'user_id' => Auth::id(),
            'name' => $this->input('name'),
            'phone' => $this->input('phone'),
            'address_district' => $this->input('address_district'),
            'address_detail' => $this->input('address_detail'),
            'province' => $this->input('province'),
            'city' => $this->input('city'),
            'district' => $this->input('district' ),
            'street' => $this->input('street'),
            'is_default'=> $this->input('is_default',0),
            'address_tag'=>$this->input('address_tag')


        ];
    }
}
